<!DOCTYPE >
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基本设置</title>

  <link rel="stylesheet" type="text/css" href="/system/css/right.css">
  <script type="text/javascript" src="/system/js/jquery.js"></script>
  <script type="text/javascript" src="/system/js/system.js"></script>
  <script type="text/javascript" src="/system/js/admin.js"></script>
	<style>
.setting .setting_t{
	padding-top:0;
}
	</style>
</head>
<body style="overflow: auto;">
	<div class="basic bor">
			<div class="title fl">当前位置：加盟商管理 > 添加会员</div>
			<div class="basic_r fr"><a href="">基本信息</a></div>
	</div>
	<div class="notice">
			<div class="n_title">
				<span class="fl">添加会员</span>

			</div>
			<div class="ncontent">
				<form action="{:url('User/edit_member')}" method="post" enctype="multipart/form-data" >
					<div class="setting">

						<ul>
							<li>
								<dd class="setting_t fl"><span>*</span> 加盟商 ：</dd>
								<dd class="setting_p fl">
									<select  name="shop_id" id="J_shop" >
										{volist name="shop_list" id ="li"}
										<option value="{$li['id']}" >{$li['name']}</option>
										{/volist}
									</select>
								</dd>
							</li>

							<li>
								<dd class="setting_t fl"><span>*</span>业务经理 ：</dd>
								<dd class="setting_p fl">
									<select  name="manager_id" id="J_manager" >

									</select>
								</dd>
							</li>

							<li>
								<dd class="setting_t fl"><span>*</span>业务员 ：</dd>
								<dd class="setting_p fl">
									<select  name="cs_id" id="J_cs" >

									</select>
								</dd>
							</li>

							<li>
								<dd class="setting_t fl"><span>*</span>用户名称 ：</dd>
								<dd class="setting_p fl"><input class="seinp" type="text" name="name" value="{$detail['name']??''}">
									<!-- <span>产品名称不能为空</span> -->
								</dd>
							</li>

							<li>
								<dd class="setting_t fl"><span>*</span>手机号码 ：</dd>
								<dd class="setting_p fl"><input class="seinp" type="text" name="mobile" value="{$detail['mobile']??''}">
									<!-- <span>产品名称不能为空</span> -->
								</dd>
							</li>

								<li>
								<dd class="setting_t fl"><span>*</span>性别 ：</dd>
								<dd class="setting_p fl">
									<select  name="sex"  >
										 <option value="0" >女</option>
										 <option value="1" >男</option>
									</select>
								</dd>
							</li>


							<li>
								<dd class="setting_t fl"><span>*</span>地址 ：</dd>
								<dd class="setting_p fl">
									省份:
									<select  name="province" id="J_province" >
										{volist name ='province_list' id = "li"}
										  {if isset($detail['province'])}
										   {if $detail['province'] == $li['areaname']}
											<option value="{$li.areaname}" data-id =""  >{$li.areaname}</option>
											{/if}
										  {else /}
					                        <option value="{$li.areaname}" data-id ="{$li.rowid}" >{$li.areaname}</option>
						                  {/if}
					                   {/volist}
									</select>城市:
									<select  name="city" id="J_city" >
										 {if isset($detail['city']) }
										  <option value="" >{$detail.city}</option>
										 {/if}
									</select>
									区:<select  name="district" id="J_cdistrict" >
										 {if isset($detail['district']) }
										  <option value="" >{$detail.district}</option>
										 {/if}
									</select>
								</dd>

							</li>
							<li>
								<dd class="setting_t fl"><span>*</span>详细地址:</dd>
								<dd class="setting_p fl">
							      <input class="seinp" type="text" name="detail" value="{$detail.detail??''}" >
							   </dd>
							</li>
							<li>
								<dd class="setting_t fl"> &nbsp;</dd>
								<dd class="setting_p fl">

								<input  type="hidden" name="id" value="{$detail['id']??''}">
								<input class="submit" type="submit" value="保存">

								</dd>
							</li>
						</ul>


					</div>
					</form>
			</div>
	</div>
 </script>
<script	>
	$(function(){

		var shop_id = $("#J_shop").val();
		if(shop_id != null){
			var data = {shop_id:shop_id};
			var ids = "J_manager";
			var url = "{:url('User/getManagerList')}";
			getlist(data,ids,url);
		}


		$("#J_shop").change(function(){
			var shop_id =  $("#J_shop").val();
			var data = {shop_id:shop_id};
			var ids = "J_manager";
			getlist(data,ids,url);
		});

		$("#J_manager").change(function(){
			var url = "{:url('User/getSaleList')}";
			var pid = $("#J_manager").val();
			var data = {pid:pid};
			var ids = "J_cs";
			getlist(data,ids,url);
		});


	 var rowsid = $("#J_province option:selected").attr("data-id");
	 if(rowsid != null){
	  getArea("060LVB","J_city")
	 }

    //获取城市列表
	$("#J_province").change(function(){
       var rowid = $("#J_province option:selected").attr("data-id");
       getArea(rowid,"J_city");
	});

	$("#J_city").change(function(){
       var rowid = $("#J_city option:selected").attr("data-id");
       getArea(rowid,"J_cdistrict");
	});

	});

/*	function getCsList(){
		var url = "{:url('User/getSaleList')}";
		var pid = $("#J_manager").val();
		console.log(pid);
		var data = {pid:pid};
		var ids = "J_cs";
		getlist(data,ids,url);
	}*/

	function getlist(data,ids,url){
		$("#"+ids).html("");
		$.ajax({
         type: "GET",
         url: url,
         data: data,
         dataType: "json",
         success: function(res){
         	if(res.code>0){
         		for (var i = 0; i < res.data.length; i++) {
         			var shtml = "<option value='"+res.data[i].id+"' >"+res.data[i].name+"</option>";
         			$("#"+ids).append(shtml);
         		}
         	}
         },
         error:function(e){

         }

	    });
	}


	function getArea(rowid,id){
		var data = {"rowid":rowid};
		$("#"+id).html("");
		$.ajax({
		url:"{:url('User/getCityList')}",
		type:'POST',
		data:{"rowid":rowid},
		dataType:'json',
		success:function(res){
		    result = res.data;
			if(result.length>0){
				getArea(result[0]['rowid'],"J_cdistrict");
				for (var i = 0; i < result.length; i++) {
			       	var shtml = '<option value="'+result[i].areaname+'"   data-id ="'+result[i].rowid+'">'+result[i].areaname+'</option>';
			       	$("#"+id).append(shtml);
			    }
			}
		}
		});
	}
</script>


</body>
</html>
